<article class="cl pd-10" style="min-width: 960px;">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="del_all()" class="btn btn-danger radius">
                <i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            <a class="btn btn-primary radius" href="javascript:void(0);" onclick="addArticle();">
                <i class="Hui-iconfont">&#xe600;</i> 添加文章</a>
                <!-- {:url('/sys/article/save', ['cid'=>$cid, 'id'=>0])} -->
        </span>
        <span>
            <form action="" method="get">
                <span class="select-box inline ml-50">
                    <select name="cid" id="sel_option" class="select">
                        <option value="0" {eq name='cid' value="0" }selected{/eq}>所有栏目</option>
                        {foreach $categories as $value}
                        <option value="{$value.id}" {eq name='cid' value="$value.id" }selected{/eq}>{$value.name_en}
                        </option>
                        {/foreach}
                    </select>
                </span>
                <input class="input-text" type="text" name="key" id="key" value="{$key}" style="width: 300px;">
                <button class="btn btn-success radius" type="button" name="search" id="search">搜索</button>
            </form>
        </span>
        <span class="r">共有数据：<strong id="total">{$list->total()}</strong>条</span>
    </div>
    <div>
        <table class="table table-border table-bordered table-bg">
            <thead>
                <!-- 1684 -->
                <tr class="text-c">
                    <th width="2%;">
                        <input type="checkbox" name="allcheck" value="">
                    </th>
                    <th width="4%">ID</th>
                    <th width="22%;">标题</th>
                    <th width="10%;">标题图</th>
                    <th width="8%;">栏目</th>
                    <th width="6%">发布者</th>
                    <th width="12%;">发布时间</th>
                    <th width="6%;">点击量</th>
                    <th width="6%">排序</th>
                    <th width="6%">审核状态</th>
                    <th width="12%;">操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach $list as $val}
                <tr class="text-c va-m" style="height: 80px;">
                    <td>
                        <input type="checkbox" value="{$val.id}" name="checkbox[]">
                    </td>
                    <td>{$val.id}</td>
                    <td class="text-l">
                        <a href="/en/news/{$val.create_time|date='Y-m-d'}/{$val.id}" style="text-decoration:none" title="浏览"
                            target="_blank">{$val.title}</a>
                    </td>
                    <td>{notempty name="val.titlepic"} <a href="{$val.titlepic}" target="_blank" class="pictureview">
                            <img src="{$val.titlepic}" title="{$val.titlepic}" style="max-height: 76px;">
                        </a>{/notempty}</td>
                    <td>{$val.category_name_en}</td>
                    <td>{$val.username}</td>
                    <td>{$val.pubtime}</td>
                    <td>{$val.hits}</td>
                    <td><input type="text" class="input-text input-sort" value="{$val.sort}" data-id="{$val.id}"
                            style="text-align: center;"></td>
                    <td class="td-status">
                        <div class="switch size-S has-switch" data-on-label="是" data-off-label="否" data-id="{$val.id}">
                            <input type="checkbox" {if $val.status==1}checked{/if}>
                        </div>
                    </td>
                    <td class="td-manage">
                        <a href="{:url('/sys/article_en/save', ['cid'=>$val['cid'], 'id'=>$val['id']])}" title="编辑"
                            class="btn btn-primary radius size-S">
                            <i class="Hui-iconfont">&#xe6df;</i></a>
                        <a href="javascript:;" title="删除" class="ml-5 btn btn-danger radius size-S"
                            onClick="del(this,'{$val.id}')">
                            <i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20 ">
        <span class="r">{$list->render()|raw}</span>
    </div>
</article>
<script>
    function addArticle() {
        var cid = $("#sel_option").val();

        if (!cid || cid == 0) {
            layer.msg("请选择栏目", {
                icon: 5,
                time: 2000
            });
            return false;
        }

        window.location.href='/sys/article_en/save?cid='+cid;
    }
    // var lay_index = 0;

    // function save(id) {
    //     var title = id == 0 ? '添加文章' : '修改文章'
    //     var url = "{:url('save')}" + "?_layer=true&id=" + id
    //     // layer_show(title, url, 960);
    //     var w = 1160;
    //     var h = ($(window).height() - 50);

    //     lay_index = layer.open({
    //         type: 2,
    //         area: [w+'px', h +'px'],
    //         fix: false, //不固定
    //         maxmin: true,
    //         shade:0.4,
    //         title: title,
    //         content: url,
    //         // console: "layer_close"
    //         end: function () {
    //             layer_close();
    //         }
    //     });
    // }

    // /*覆盖 plugins/h-ui.admin/js/H-ui.admin.page.js 中的 layer_close 关闭弹出框口*/
    // function layer_close(){
    //     console.log(123);
    //     layer.close(lay_index);
    //     window.location.reload(); // 父页面刷新
    // }
</script>